﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace webnew.UserControls
{
    public partial class Uc_Calenderhhmmss : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "calendar", "/Js/DatePicker/WdatePicker.js");

        }
        /// <summary>
        /// 设置并获取日期控件文本
        /// </summary>
        public string Text
        {
            get { return txtCalendar.Text; }
            set {
                txtCalendar.Text = ConvertNullTime(value);               
            }
        }

        private string ConvertNullTime(string strtime)
        {
             if (strtime == DateTime.MinValue.ToString() || strtime == DateTime.MinValue.ToShortDateString() || strtime == "" || strtime == null)           
            {
                return "";
            }
            else
                return Convert.ToDateTime(strtime).ToString("yyyy-MM-dd HH:mm:ss");
        }

        /// <summary>
        /// 设置日期控件是否启用
        /// </summary>
        public bool Enabled
        {
            get { return txtCalendar.Enabled; }
            set { txtCalendar.Enabled = value; }
        }

        /// <summary>
        /// 设置是否回发事件
        /// </summary>
        public bool AutoPostBack
        {
            get
            {
                return txtCalendar.AutoPostBack;
            }
            set
            {
                txtCalendar.AutoPostBack = value;
            }
        }
    }
}